package com.sky.controller.user;

import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("userCategoryController")
@RequestMapping("/user/category")
@Api(tags = "分类")
@Slf4j
public class CategoryController {

    @Autowired
    private CategoryService categoryService;
    @GetMapping("/list")
    @ApiOperation("分类查询(菜品或套餐)")
    public Result<List> list(Integer type){
        log.info("用户端分类查询:{}",type == null ? "查询菜品和套餐" : (type == 1?  "菜品"  :  "套餐"));
        List<Category> categories = categoryService.typeList(type);
        return Result.success(categories);
    }
}
